import React from "react";
// NavLink和Link一样，是用来做路由跳转的
// Link的功能NavLink都有，并且多了一个高亮的效果
import { Route, Switch, Redirect, NavLink } from "react-router-dom";

import "./08-style.css";

class Home extends React.Component {
  render() {
    return (
      <>
        <div>home页面</div>
      </>
    );
  }
}

const About = () => {
  return <div>about页面</div>;
};

const App = () => {
  return (
    <>
      <h2>react-router-v5-导航高亮</h2>
      <ul>
        <li>
          <NavLink to="/" activeClassName="select" exact>
            首页
          </NavLink>
        </li>
        <li>
          <NavLink to="/about" activeClassName="select">
            关于页
          </NavLink>
        </li>
      </ul>

      <hr />

      <Switch>
        {/* <Redirect from="/" to="/home" exact></Redirect> */}
        <Route path="/" component={Home} exact></Route>
        <Route path="/about" component={About}></Route>
      </Switch>
    </>
  );
};

export default App;
